home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 23 / AMIGAplus Sonderheft 23 (2000)(Falke)(DE)[!].iso / Updates / Librarys / MMULib / Include / mmu / exceptions.i < prev    next >
Text File  |  1999-10-30  |  11KB  |  288 lines

  1.         IFND MMU_EXCEPTIONS_I
  2. MMU_EXCEPTIONS_I        SET     1
  3. ;*************************************************************************
  4. ;** mmu.library                                                         **
  5. ;**                                                                     **
  6. ;** a system library for arbitration and control of the MC68K MMUs      **
  7. ;**                                                                     **
  8. ;** © 1998 THOR-Software, Thomas Richter                                **
  9. ;** No commercial use, reassembly, modification without prior, written  **
  10. ;** permission of the authors.                                          **
  11. ;** Including this library in any commercial software REQUIRES a        **
  12. ;** written permission and the payment of a small fee.                  **
  13. ;**                                                                     **
  14. ;**---------------------------------------------------------------------**
  15. ;** exception related definitions                                       **
  16. ;**                                    **
  17. ;** $VER: 40.50 (31.10.99)                        **
  18. ;*************************************************************************
  19.  
  20.         IFND EXEC_TYPES_I
  21.         INCLUDE "exec/types.i"
  22.         ENDC ; EXEC_TYPES_I
  23.  
  24.         IFND EXEC_PORTS_I
  25.         INCLUDE "exec/ports.i"
  26.         ENDC ; EXEC_PORTS_I
  27.  
  28.         IFND EXEC_INTERRUPTS_I
  29.         INCLUDE "exec/interrupts.i"
  30.         ENDC ; EXEC_INTERRUPTS_I
  31.  
  32.  
  33. ;* The exception data structure. This structure is passed in register a0
  34. ;* for exception hooks and is the one and only information source about
  35. ;* the exception. This structure will be deleted as soon as the exception
  36. ;* terminates, hence make a copy for private use if you need to pass it
  37. ;* over to someone else.
  38.  
  39.     STRUCTURE ExceptionData,0
  40.         APTR            exd_Task                ;struct Task *
  41. ;* The task that caused the exception. Meaningless if this is the exception
  42. ;* handler of the (a) supervisor context. *
  43.  
  44.         APTR            exd_Context             ;struct MMUContext *
  45. ;* The context this exception is part of. *
  46.  
  47.         APTR            exd_Descriptor          ;ULONG *
  48. ;* The true physical hardware descriptor as seen by the MMU. In case of
  49. ;* an indirect descriptor, this points to the pointer, not to (your) page
  50. ;* descriptor itself. *
  51.  
  52.         APTR            exd_NextDescriptor      ;ULONG *
  53. ;* In case of a misaligned access, i.e. an access that passes a page
  54. ;* boundary, the descriptor of the second page involved in the access.
  55. ;* Otherwise identical to exd_Descriptor *
  56.  
  57.         APTR            exd_FaultAddress
  58. ;* The address that failed. *
  59.  
  60.         APTR            exd_NextFaultAddress
  61. ;* This is the final end address, inclusively, of a failed access.
  62. ;* Note that this might well be less than "exd_FaultAddress", e.g. if the
  63. ;* faulty instruction is a movem.l regs,-(ax).
  64. ;*
  65. ;* ABS(exd_FaultAdress-exd_NextFaultAddress)+1 is the size of the access
  66. ;* that failed. Usually 1, 2 and 4 for byte, word and longword accesses, but
  67. ;* other sizes are possible as well. In case you're writing a swapper daemon,
  68. ;* make sure you make all addresses within this range valid.
  69.  
  70.  
  71.         ULONG           exd_UserData
  72. ;* User data for the first page in the failed access if available. This is
  73. ;* the block Id for swapped out pages. *
  74.  
  75.         ULONG           exd_NextUserData
  76. ;* User data for the second page in a misaligned access. Identical to
  77. ;* exd_UserData otherwise. *
  78.  
  79.         ULONG           exd_Data
  80. ;* CPU output pipeline, right justified, if available, i.e. if the page(s)
  81. ;* is (are) marked as MAPP_REPAIRABLE.
  82. ;* Can be modified for your code, provided you set the EXDF_READBACK flag
  83. ;* and the page is repairable. In this case, this data will be loaded back
  84. ;* to the input pipeline of the CPU. *
  85.  
  86.         APTR            exd_ReturnPC
  87. ;* The approximate PC of the faulted instruction. Note that the real PC
  88. ;* might differ due to instruction prefetch. The program is guaranteed
  89. ;* to continue the "right" PC, however.
  90. ;* In case you set the EXDF_CALL flag, this is the pointer to a routine that
  91. ;* will be called by the library in user mode, e.g. for posting a message
  92. ;* to the swapper daemon. *
  93.  
  94.         ULONG           exd_Flags
  95. ;* A flags field, see below for the definitions. *
  96.  
  97.         ULONG           exd_Properties
  98. ;* Properties of the accessed memory *
  99.  
  100.         ULONG           exd_NextProperties
  101. ;*Properties of the next descriptor, if misaligned *
  102.  
  103.         UBYTE           exd_internal
  104. ;* Do not read or write this byte. *
  105.  
  106.         UBYTE           exd_FunctionCode
  107. ;* The function code mask of the access. *
  108.  
  109.         BYTE            exd_Level
  110. ;* The level of the *exd_Descriptor responsible for the fault. "0" is the
  111. ;* level A, "1" is level B and so on. Note that this is different from how
  112. ;* the 680x0 MMUs count. *
  113.  
  114.         BYTE            exd_NextLevel
  115. ;* The level of the *exd_NextDescriptor in case of a misalgined access.
  116. ;* Identical to exd_Level otherwise. *
  117.  
  118.         STRUCT          exd_DataRegs,8*4
  119. ;* A copy of the data registers of the faulty program. For higher magic,
  120. ;* you *might* be able to modify these. *
  121.  
  122.         STRUCT          exd_AddrRegs,7*4
  123. ;* A copy of the address registers, a0 to a6. a7 is below. *
  124.  
  125.         APTR            exd_SSP
  126. ;* The supervisor stack pointer, points to the exception stack frame.
  127. ;* DO NOT touch this stack frame, this is the buisiness of the library. *
  128.  
  129.         APTR            exd_USP
  130. ;* The user stack pointer. *
  131.  
  132.         APTR            exd_SysBase     ;struct SysBase *
  133. ;* A cached copy of the exec.library base address. DO NOT access AbsExecBase
  134. ;* within an exception handler, this will be fatal. Use either a private
  135. ;* copy or this field. *
  136.  
  137.         APTR            exd_MMUBase     ;struct MMUBase *
  138. ;* The base of the mmu.library. *
  139.  
  140.         LABEL           exd_SIZE
  141.  
  142. ;*************************************************************************
  143. ;* The flags set in exd_Flags, above. Note that there are more flags than
  144. ;* documented here, but DO NOT touch or interpret these.
  145.  
  146. ;* input flags    (set by the exception handler)        *
  147.  
  148.  
  149. EXDF_WRITE              equ     (1<<0)
  150. EXDB_WRITE              equ     0
  151. ;* A faulty write if set. A read exception if reset.
  152. ;* A 060 read/modify/write access will invoke the exception handler twice.
  153. ;* Note that locked transfers (what is called a RMW-access on a 020 or 030)
  154. ;* are neither handled by the Amiga hardware nor the mmu.library software. *
  155.  
  156. EXDF_INSTRUCTION        equ     (1<<1)
  157. EXDB_INSTRUCTION        equ     1
  158. ;* A faulty instruction access. This means specifically that you MAY NOT
  159. ;* provide read-back data. You've either to stop the task, or swap in a page.
  160. ;* Note that EXDF_WRITE and EXDF_INSTRUCTION are possible in case a faulty
  161. ;* program uses a "moves" instruction with the dfc register loaded with an
  162. ;* instruction function code. Note, too, that the os never tries to do that
  163. ;* and that this method is not supported by the mmu.library. *
  164.  
  165. EXDF_WRITEPROTECTED     equ     (1<<2)
  166. EXDB_WRITEPROTECTED     equ     2
  167. ;* The fault was due to a write to a write protected page. *
  168.  
  169. EXDF_WRITEDATAUNKNOWN   equ     (1<<3)
  170. EXDB_WRITEDATAUNKNOWN   equ     3
  171. ;* The mmu library could not get hold of the data actually written out,
  172. ;* exd_Data is invalid. Set pages to MAPP_REPAIRABLE to get write data. *
  173.  
  174. EXDF_SUPERVISOR         equ     (1<<6)
  175. EXDB_SUPERVISOR         equ     6
  176. ;* The fault was due to access of a supervisor only page. *
  177.  
  178. EXDF_MISALIGNED         equ     (1<<8)
  179. EXDB_MISALIGNED         equ     8
  180. ;* The access spawned more than one page in memory. *
  181.  
  182.  
  183. ;* The following flags are output flags. You may set them in your code and
  184. ;* they are respected by the library. *
  185.  
  186. EXDF_READBACK           equ     (1<<16)
  187. EXDB_READBACK           equ     16
  188. ;* Fill the input pipeline of the CPU with the data in exd_Data, right
  189. ;* justified. *
  190.  
  191. EXDF_WRITECOMPLETE      equ     (1<<16)         ;* yes, the same number *
  192. EXDB_WRITECOMPLETE      equ     16
  193. ;* The exception handler was able to perform the writeback of exd_Data,
  194. ;* the CPU should ignore the faulty write and continue execution.
  195. ;* If this bit is not set, the access is retried. *
  196.  
  197. EXDF_CALL               equ     (